package com.ruoyi.web.tdm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.tdm.domain.TdmKangTiYaoWu;
import com.ruoyi.web.tdm.service.ITdmKangTiYaoWuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抗体药物Controller
 * 
 * @author ly
 * @date 2022-03-11
 */
@RestController
@RequestMapping("/tdm/TdmKangTiYaoWu")
public class TdmKangTiYaoWuController extends BaseController
{
    @Autowired
    private ITdmKangTiYaoWuService tdmKangTiYaoWuService;

    /**
     * 查询抗体药物列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmKangTiYaoWu:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmKangTiYaoWu tdmKangTiYaoWu)
    {
        startPage();
        List<TdmKangTiYaoWu> list = tdmKangTiYaoWuService.selectTdmKangTiYaoWuList(tdmKangTiYaoWu);
        return getDataTable(list);
    }

    /**
     * 导出抗体药物列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmKangTiYaoWu:export')")
    @Log(title = "抗体药物", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmKangTiYaoWu tdmKangTiYaoWu)
    {
        List<TdmKangTiYaoWu> list = tdmKangTiYaoWuService.selectTdmKangTiYaoWuList(tdmKangTiYaoWu);
        ExcelUtil<TdmKangTiYaoWu> util = new ExcelUtil<TdmKangTiYaoWu>(TdmKangTiYaoWu.class);
        util.exportExcel(response, list, "抗体药物数据");
    }

    /**
     * 获取抗体药物详细信息
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmKangTiYaoWu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmKangTiYaoWuService.selectTdmKangTiYaoWuById(id));
    }

    /**
     * 新增抗体药物
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmKangTiYaoWu:add')")
    @Log(title = "抗体药物", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmKangTiYaoWu tdmKangTiYaoWu)
    {
        return toAjax(tdmKangTiYaoWuService.insertTdmKangTiYaoWu(tdmKangTiYaoWu));
    }

    /**
     * 修改抗体药物
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmKangTiYaoWu:edit')")
    @Log(title = "抗体药物", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmKangTiYaoWu tdmKangTiYaoWu)
    {
        return toAjax(tdmKangTiYaoWuService.updateTdmKangTiYaoWu(tdmKangTiYaoWu));
    }

    /**
     * 删除抗体药物
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmKangTiYaoWu:remove')")
    @Log(title = "抗体药物", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmKangTiYaoWuService.deleteTdmKangTiYaoWuByIds(ids));
    }
}
